<?php 

$pidArr = [];

for($i=0;$i<3;$i++){
	$pid = pcntl_fork();

	if ($pid == -1) {

	     die('could not fork');
	} else if ($pid) {

		$pidArr[] = $pid;
	     //pcntl_wait($status); 

	     //echo "parents pid",PHP_EOL;
	     //echo "pid=>",posix_getpid(),PHP_EOL;
	     //die("parents die");

	} else {


		echo "child pid",PHP_EOL;
		echo "pid=>",posix_getpid(),PHP_EOL;
	}
}
foreach($pidArr as $wpid){
	pcntl_wait()
}